<?php
/**
 * Prado Portal.
 *
 * @author Steen Rabol <steen.rabol@gmail.com>
 * @link http://www.pradoportal.dk/
 * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
 * @license http://www.pradoportal.dk
 * @version $Id: XListMenuPortlet.php 418 2011-01-04 21:31:53Z steen.rabol $
 *
 */

Prado::using('Application.Portlets.Portlet');
Prado::using('Application.Common.XListMenu');
class XListMenuPortlet extends Portlet
{
	public function onLoad($param)
	{
		parent::onLoad($param);

		$mainmenu	= new XListMenu();
		try
		{
			$pages		= $this->DataAccess->createCommand("select * from tblpages where active=1 order by displayorder")->query();
		}
		catch(Exception $e)
		{
			throw new PortalException(1,$e->getMessage());
		}

		if($pages !== null && count($pages) >0)
		{
			foreach($pages as $page)
			{
				$mi					= new XListMenuItem();
				$mi->PagePath		= $page['displayname'];
				$mi->NavigateUrl	= $this->Service->constructUrl($page['name']);
				$mi->Text			= $page['displayname'];
				$mainmenu->Controls[] = $mi;
			}
		}

		$this->XListMenuPlaceholder->Controls[] = $mainmenu;
	}
}
?>